package model

import (
	"gorm.io/gorm"
	"time"
)

type Table struct {
	ID        uint           `gorm:"primarykey" json:"id"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
	Name      string         `json:"name"`
	Columns   []Column       `json:"columns"`
}

type Column struct {
	ID        uint           `gorm:"primarykey" json:"id"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
	TableID   uint           `json:"table_id"`
	Type      string         `json:"type"`
	Title     string         `json:"title"`
	DataIndex string         `json:"data_index"`
	Order     uint           `json:"order"`
}

type Datasource struct {
	ID        uint           `gorm:"primarykey" json:"id"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
	Type      string         `json:"type"`
	MySQLDSN  string         `gorm:"column:mysql_dsn" json:"mysql_dsn"`
	SQL       string         `json:"sql"`
	URL       string         `json:"url"`
}
